package com.company.project.common.job.task;

import com.company.project.common.redismq.ZSetVer;
import com.company.project.common.utils.StringUtil;
import com.company.project.service.RedisService;
import com.company.project.service.TCallbakService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 测试定时任务(演示Demo，可删除)
 * testTask为spring bean的名称， 方法名称必须是run
 *
 * @author wenbin
 * @version V1.0
 * @date 2020年3月18日
 */
@Slf4j
@Component("callBackTask")
public class CallBackTask {
	public final static String RS_ZS_MQ_ME = "consumerDelayMessage:";
	@Resource
	public RedisService redisService;
	@Resource
	private ZSetVer zSetVer;
	@Resource
	public TCallbakService tCallbakService;
//	@Transactional
	public void run(String params){
//		List<TCallbakEntity> list = tCallbakService.getListByLimit(1000);
//		for(TCallbakEntity entity : list){
//			String jsonString = JSON.toJSONString(entity);
//			zSetVer.producer("id",jsonString);
//		}
//		zSetVer.consumerDelayMessage("id");

		String key = "callBackTask";
		String s = redisService.get(RS_ZS_MQ_ME+key);
		if (StringUtil.equals("false",s)||StringUtil.isBlank(s)) {
			zSetVer.consumerDelayMessageData(key);
		}
	}
}
